package com.suma.platform.core.service;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;

/**
 * @author suma
 * @date 2018/2/24 上午9:36
 */
@Slf4j
@Service
public class RedisCacheService {

	@Autowired
	RedisTemplate<String, Object> redisTemplate;

	public void set(String key, Object value) {
		this.set(key, value, 0L, TimeUnit.MILLISECONDS);
	}

	public void set(String key, Object value, Long timeout, TimeUnit timeUnit) {
		ValueOperations<String, Object> operations = redisTemplate.opsForValue();
		operations.set(key, value, timeout, timeUnit);
	}

	public void multiSet(Map<String, Object> map) {
		ValueOperations<String, Object> operations = redisTemplate.opsForValue();
		operations.multiSet(map);
	}

}
